<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" media="screen" href="../../css/bootstrap.min.css">
</head>
<body>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
	<form class="form-horizontal" onsubmit="return false" id="form">
		<fieldset>
			<input type="hidden" id="id" name="id">
			<div class='form-group'>
				<label class='col-md-2 control-label'>method</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='method' type='text' name='method' id='method' data-bv-notempty='true' data-bv-notempty-message='method 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>minPostageFree</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='minPostageFree' type='text' name='minPostageFree' id='minPostageFree' data-bv-notempty='true' data-bv-notempty-message='minPostageFree 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>mailPrice</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='mailPrice' type='text' name='mailPrice' id='mailPrice' data-bv-notempty='true' data-bv-notempty-message='mailPrice 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>state</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='state' type='text' name='state' id='state' data-bv-notempty='true' data-bv-notempty-message='state 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>whether</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='whether' type='text' name='whether' id='whether' data-bv-notempty='true' data-bv-notempty-message='whether 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>receiveArea</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='receiveArea' type='text' name='receiveArea' id='receiveArea' data-bv-notempty='true' data-bv-notempty-message='receiveArea 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>insurancePrice</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='insurancePrice' type='text' name='insurancePrice' id='insurancePrice' data-bv-notempty='true' data-bv-notempty-message='insurancePrice 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>insuranceInformation</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='insuranceInformation' type='text' name='insuranceInformation' id='insuranceInformation' data-bv-notempty='true' data-bv-notempty-message='insuranceInformation 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>creater</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='creater' type='text' name='creater' id='creater' data-bv-notempty='true' data-bv-notempty-message='creater 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>updater</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='updater' type='text' name='updater' id='updater' data-bv-notempty='true' data-bv-notempty-message='updater 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>mailNote</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='mailNote' type='text' name='mailNote' id='mailNote' data-bv-notempty='true' data-bv-notempty-message='mailNote 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>mailRemark</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='mailRemark' type='text' name='mailRemark' id='mailRemark' data-bv-notempty='true' data-bv-notempty-message='mailRemark 不能为空'>
				</div>
			</div>



			<div class="form-actions">
				<div class="row" align="center">
					<div class="col-md-12">
					    <button class="btn btn-primary" onclick="location.href='tswProductMailList.html'">返回</button>
						<button class="btn btn-primary" type="submit" onclick="update()">
							<i class="fa fa-save"></i> 保存
						</button>
					</div>
				</div>
			</div>

		</fieldset>
	</form>
</div>
	<script type="text/javascript" src="../../js/libs/jquery-2.1.1.min.js"></script>
	<script type="text/javascript" src="../../js/jq.js"></script>
	<script type="text/javascript" src="../../js/plugin/bootstrapvalidator/bootstrapValidator.min.js"></script>
	<script type="text/javascript" src="../../js/common.js"></script>
	<script type="text/javascript" src="../../layui/layui.js"></script>
	<script type="text/javascript">
		layui.use(['layer','laydate'], function(){
		    var layer = layui.layer;
		});
		
		initData();
		
		function initData(){
			var id = getUrlParam("id");
			if(id != ""){
				$.ajax({
					type : 'get',
					url : '/tswProductMails/'+id,
					async : false,
					success : function(data) {
						$('#id').val(data.id);
						$('#method').val(data.method);
						$('#minPostageFree').val(data.minPostageFree);
						$('#mailPrice').val(data.mailPrice);
						$('#state').val(data.state);
						$('#whether').val(data.whether);
						$('#receiveArea').val(data.receiveArea);
						$('#insurancePrice').val(data.insurancePrice);
						$('#insuranceInformation').val(data.insuranceInformation);
						$('#createTime').val(data.createTime);
						$('#creater').val(data.creater);
						$('#updateTime').val(data.updateTime);
						$('#updater').val(data.updater);
						$('#mailNote').val(data.mailNote);
						$('#mailRemark').val(data.mailRemark);

					}
				});
			}
		}

		function update() {
			$('#form').bootstrapValidator();
			var bootstrapValidator = $("#form").data('bootstrapValidator');
			bootstrapValidator.validate();
		    if(!bootstrapValidator.isValid()){
			   return;
		    }
		    
		    var formdata = $("#form").serializeObject();

			$.ajax({
				type : 'put',
				url : '/tswProductMails',
				contentType: "application/json; charset=utf-8",  
				data : JSON.stringify(formdata),
				success : function(data) {
					layer.msg("修改成功", {shift: -1, time: 1000}, function(){
                        location.href = "tswProductMailList.html";
                    });
				}
			});
		}
		
	</script>
</body>
</html>
